[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[OPTIMIZE 1]
[OPTION 1]
[BITS 32]
	EXTERN	_memman_alloc_4k
	EXTERN	_memman_free_4k
[FILE "sheet.c"]
[SECTION .text]
	ALIGN	2
	GLOBAL	_shtctl_init
_shtctl_init:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	MOV	ESI,DWORD [8+EBP]
	PUSH	10260
	MOV	EDI,DWORD [16+EBP]
	PUSH	ESI
	CALL	_memman_alloc_4k
	MOV	EBX,EAX
	POP	EAX
	POP	EDX
	TEST	EBX,EBX
	JE	L3
	MOV	EAX,DWORD [20+EBP]
	IMUL	EAX,EDI
	PUSH	EAX
	PUSH	ESI
	CALL	_memman_alloc_4k
	TEST	EAX,EAX
	MOV	DWORD [4+EBX],EAX
	POP	EDX
	POP	ECX
	JE	L11
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [8+EBX],EDI
	MOV	DWORD [EBX],EAX
	LEA	EDX,DWORD [9180+EBX]
	MOV	EAX,DWORD [20+EBP]
	MOV	DWORD [12+EBX],EAX
	MOV	EAX,EBX
	MOV	DWORD [16+EBX],-1
L9:
	MOV	DWORD [1072+EAX],0
	MOV	DWORD [1076+EAX],EBX
	ADD	EAX,36
	CMP	EAX,EDX
	JLE	L9
L3:
	LEA	ESP,DWORD [-12+EBP]
	MOV	EAX,EBX
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L11:
	PUSH	10260
	PUSH	EBX
	PUSH	ESI
	CALL	_memman_free_4k
	ADD	ESP,12
	JMP	L3
	ALIGN	2
	GLOBAL	_sheet_alloc
_sheet_alloc:
	PUSH	EBP
	XOR	EDX,EDX
	MOV	EBP,ESP
	MOV	EAX,DWORD [8+EBP]
	ADD	EAX,1044
L18:
	CMP	DWORD [28+EAX],0
	JE	L21
	INC	EDX
	ADD	EAX,36
	CMP	EDX,255
	JLE	L18
	XOR	EAX,EAX
L12:
	POP	EBP
	RET
L21:
	MOV	DWORD [28+EAX],1
	MOV	DWORD [24+EAX],-1
	JMP	L12
	ALIGN	2
	GLOBAL	_sheet_setbuf
_sheet_setbuf:
	PUSH	EBP
	MOV	EBP,ESP
	MOV	EDX,DWORD [8+EBP]
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [EDX],EAX
	MOV	EAX,DWORD [16+EBP]
	MOV	DWORD [4+EDX],EAX
	MOV	EAX,DWORD [20+EBP]
	MOV	DWORD [8+EDX],EAX
	MOV	EAX,DWORD [24+EBP]
	MOV	DWORD [20+EDX],EAX
	POP	EBP
	RET
	ALIGN	2
	GLOBAL	_sheet_refreshmap
_sheet_refreshmap:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	SUB	ESP,40
	MOV	EAX,DWORD [8+EBP]
	CMP	DWORD [12+EBP],0
	MOV	EAX,DWORD [4+EAX]
	MOV	DWORD [-40+EBP],EAX
	JS	L54
L24:
	CMP	DWORD [16+EBP],0
	JS	L55
L25:
	MOV	EDX,DWORD [8+EBP]
	MOV	EAX,DWORD [8+EDX]
	CMP	DWORD [20+EBP],EAX
	JLE	L26
	MOV	DWORD [20+EBP],EAX
L26:
	MOV	ESI,DWORD [8+EBP]
	MOV	EAX,DWORD [12+ESI]
	CMP	DWORD [24+EBP],EAX
	JLE	L27
	MOV	DWORD [24+EBP],EAX
L27:
	MOV	EAX,DWORD [8+EBP]
	MOV	EDI,DWORD [28+EBP]
	MOV	DWORD [-16+EBP],EDI
	CMP	EDI,DWORD [16+EAX]
	JG	L49
L47:
	MOV	ESI,DWORD [8+EBP]
	MOV	EDX,DWORD [-16+EBP]
	MOV	EBX,DWORD [16+EBP]
	MOV	ECX,DWORD [20+ESI+EDX*4]
	MOV	EAX,ECX
	SUB	EAX,ESI
	MOV	EDI,DWORD [ECX]
	SUB	EAX,1044
	MOV	EDX,DWORD [16+ECX]
	SAR	EAX,2
	MOV	DWORD [-32+EBP],EDI
	IMUL	EAX,EAX,954437177
	MOV	EDI,DWORD [24+EBP]
	SUB	EBX,EDX
	SUB	EDI,EDX
	MOV	BYTE [-33+EBP],AL
	MOV	ESI,DWORD [20+EBP]
	MOV	EDX,DWORD [12+EBP]
	MOV	EAX,DWORD [12+ECX]
	MOV	DWORD [-44+EBP],EDI
	SUB	ESI,EAX
	SUB	EDX,EAX
	MOV	DWORD [-52+EBP],ESI
	MOV	DWORD [-28+EBP],EDX
	JS	L56
L32:
	TEST	EBX,EBX
	JS	L57
L33:
	MOV	EAX,DWORD [4+ECX]
	CMP	DWORD [-52+EBP],EAX
	JLE	L34
	MOV	DWORD [-52+EBP],EAX
L34:
	MOV	EAX,DWORD [8+ECX]
	CMP	DWORD [-44+EBP],EAX
	JLE	L35
	MOV	DWORD [-44+EBP],EAX
L35:
	CMP	EBX,DWORD [-44+EBP]
	JGE	L51
L46:
	MOV	ESI,DWORD [16+ECX]
	MOV	EDX,DWORD [-28+EBP]
	ADD	ESI,EBX
	CMP	EDX,DWORD [-52+EBP]
	MOV	DWORD [-24+EBP],ESI
	JGE	L53
L45:
	MOV	EAX,EBX
	MOV	EDI,DWORD [12+ECX]
	IMUL	EAX,DWORD [4+ECX]
	ADD	EDI,EDX
	MOV	ESI,DWORD [-32+EBP]
	ADD	EAX,EDX
	MOV	DWORD [-20+EBP],EDI
	MOVZX	ESI,BYTE [EAX+ESI*1]
	CMP	ESI,DWORD [20+ECX]
	JE	L42
	MOV	EDI,DWORD [8+EBP]
	MOV	EAX,DWORD [-24+EBP]
	MOV	ESI,DWORD [-40+EBP]
	IMUL	EAX,DWORD [8+EDI]
	ADD	EAX,DWORD [-20+EBP]
	MOV	DWORD [-48+EBP],EAX
	MOV	AL,BYTE [-33+EBP]
	MOV	EDI,DWORD [-48+EBP]
	MOV	BYTE [EDI+ESI*1],AL
L42:
	INC	EDX
	CMP	EDX,DWORD [-52+EBP]
	JL	L45
L53:
	INC	EBX
	CMP	EBX,DWORD [-44+EBP]
	JL	L46
L51:
	MOV	EDX,DWORD [8+EBP]
	INC	DWORD [-16+EBP]
	MOV	EAX,DWORD [-16+EBP]
	CMP	EAX,DWORD [16+EDX]
	JLE	L47
L49:
	ADD	ESP,40
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L57:
	XOR	EBX,EBX
	JMP	L33
L56:
	MOV	DWORD [-28+EBP],0
	JMP	L32
L55:
	MOV	DWORD [16+EBP],0
	JMP	L25
L54:
	MOV	DWORD [12+EBP],0
	JMP	L24
	ALIGN	2
	GLOBAL	_sheet_refreshsub
_sheet_refreshsub:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	SUB	ESP,44
	MOV	EAX,DWORD [8+EBP]
	MOV	EDX,DWORD [8+EBP]
	CMP	DWORD [12+EBP],0
	MOV	EAX,DWORD [EAX]
	MOV	EDX,DWORD [4+EDX]
	MOV	DWORD [-36+EBP],EAX
	MOV	DWORD [-40+EBP],EDX
	JS	L89
L59:
	CMP	DWORD [16+EBP],0
	JS	L90
L60:
	MOV	ESI,DWORD [8+EBP]
	MOV	EAX,DWORD [8+ESI]
	CMP	DWORD [20+EBP],EAX
	JLE	L61
	MOV	DWORD [20+EBP],EAX
L61:
	MOV	EDI,DWORD [8+EBP]
	MOV	EAX,DWORD [12+EDI]
	CMP	DWORD [24+EBP],EAX
	JLE	L62
	MOV	DWORD [24+EBP],EAX
L62:
	MOV	EAX,DWORD [28+EBP]
	MOV	EDX,DWORD [32+EBP]
	MOV	DWORD [-16+EBP],EAX
	CMP	EAX,EDX
	JG	L84
L82:
	MOV	EDI,DWORD [8+EBP]
	MOV	ESI,DWORD [-16+EBP]
	MOV	ECX,DWORD [16+EBP]
	MOV	EBX,DWORD [20+EDI+ESI*4]
	MOV	ESI,DWORD [20+EBP]
	MOV	EAX,DWORD [EBX]
	MOV	EDX,DWORD [16+EBX]
	MOV	DWORD [-32+EBP],EAX
	SUB	ECX,EDX
	MOV	EAX,EBX
	SUB	EAX,EDI
	MOV	EDI,DWORD [24+EBP]
	SUB	EAX,1044
	SUB	EDI,EDX
	SAR	EAX,2
	MOV	EDX,DWORD [12+EBP]
	IMUL	EAX,EAX,954437177
	MOV	BYTE [-41+EBP],AL
	MOV	DWORD [-56+EBP],EDI
	MOV	EAX,DWORD [12+EBX]
	SUB	ESI,EAX
	SUB	EDX,EAX
	MOV	DWORD [-28+EBP],ESI
	MOV	DWORD [-24+EBP],EDX
	JS	L91
L67:
	TEST	ECX,ECX
	JS	L92
L68:
	MOV	EAX,DWORD [4+EBX]
	CMP	DWORD [-28+EBP],EAX
	JLE	L69
	MOV	DWORD [-28+EBP],EAX
L69:
	MOV	EAX,DWORD [8+EBX]
	CMP	DWORD [-56+EBP],EAX
	JLE	L70
	MOV	DWORD [-56+EBP],EAX
L70:
	MOV	ESI,ECX
	CMP	ECX,DWORD [-56+EBP]
	JGE	L86
L81:
	MOV	EDI,DWORD [16+EBX]
	MOV	ECX,DWORD [-24+EBP]
	ADD	EDI,ESI
	CMP	ECX,DWORD [-28+EBP]
	MOV	DWORD [-20+EBP],EDI
	JGE	L88
L80:
	MOV	EDX,DWORD [8+EBP]
	MOV	EDI,DWORD [-20+EBP]
	MOV	EAX,DWORD [12+EBX]
	IMUL	EDI,DWORD [8+EDX]
	ADD	EAX,ECX
	MOV	DL,BYTE [-41+EBP]
	ADD	EAX,EDI
	MOV	EDI,DWORD [-40+EBP]
	MOV	DWORD [-52+EBP],EAX
	CMP	BYTE [EAX+EDI*1],DL
	JE	L93
L77:
	INC	ECX
	CMP	ECX,DWORD [-28+EBP]
	JL	L80
L88:
	INC	ESI
	CMP	ESI,DWORD [-56+EBP]
	JL	L81
L86:
	MOV	ESI,DWORD [32+EBP]
	INC	DWORD [-16+EBP]
	CMP	DWORD [-16+EBP],ESI
	JLE	L82
L84:
	ADD	ESP,44
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L93:
	MOV	EAX,ESI
	MOV	EDX,DWORD [-32+EBP]
	IMUL	EAX,DWORD [4+EBX]
	ADD	EAX,ECX
	MOV	EDI,DWORD [-36+EBP]
	MOV	AL,BYTE [EAX+EDX*1]
	MOV	EDX,DWORD [-52+EBP]
	MOV	BYTE [EDX+EDI*1],AL
	JMP	L77
L92:
	XOR	ECX,ECX
	JMP	L68
L91:
	MOV	DWORD [-24+EBP],0
	JMP	L67
L90:
	MOV	DWORD [16+EBP],0
	JMP	L60
L89:
	MOV	DWORD [12+EBP],0
	JMP	L59
	ALIGN	2
	GLOBAL	_sheet_updown
_sheet_updown:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	PUSH	ECX
	MOV	EDI,DWORD [8+EBP]
	MOV	EBX,DWORD [12+EBP]
	MOV	ESI,DWORD [32+EDI]
	MOV	EAX,DWORD [24+EDI]
	MOV	DWORD [-16+EBP],EAX
	MOV	EAX,DWORD [16+ESI]
	INC	EAX
	CMP	EBX,EAX
	JLE	L95
	MOV	EBX,EAX
L95:
	CMP	EBX,-1
	JGE	L96
	OR	EBX,-1
L96:
	MOV	DWORD [24+EDI],EBX
	CMP	DWORD [-16+EBP],EBX
	JLE	L97
	TEST	EBX,EBX
	JS	L98
	MOV	ECX,DWORD [-16+EBP]
L103:
	MOV	EAX,DWORD [16+ESI+ECX*4]
	MOV	DWORD [20+ESI+ECX*4],EAX
	MOV	DWORD [24+EAX],ECX
	DEC	ECX
	CMP	ECX,EBX
	JG	L103
	MOV	DWORD [20+ESI+EBX*4],EDI
	INC	EBX
	PUSH	EBX
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshmap
	PUSH	DWORD [-16+EBP]
L133:
	PUSH	EBX
L132:
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshsub
	ADD	ESP,52
L94:
	LEA	ESP,DWORD [-12+EBP]
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L98:
	MOV	EAX,DWORD [16+ESI]
	CMP	EAX,DWORD [-16+EBP]
	JLE	L105
	MOV	ECX,DWORD [-16+EBP]
	CMP	ECX,EAX
	JGE	L105
L110:
	MOV	EAX,DWORD [24+ESI+ECX*4]
	MOV	DWORD [20+ESI+ECX*4],EAX
	MOV	DWORD [24+EAX],ECX
	INC	ECX
	CMP	ECX,DWORD [16+ESI]
	JL	L110
L105:
	DEC	DWORD [16+ESI]
	PUSH	0
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshmap
	MOV	EAX,DWORD [-16+EBP]
	DEC	EAX
	PUSH	EAX
	PUSH	0
	JMP	L132
L97:
	CMP	DWORD [-16+EBP],EBX
	JGE	L94
	CMP	DWORD [-16+EBP],0
	JS	L113
	MOV	ECX,DWORD [-16+EBP]
	CMP	ECX,EBX
	JGE	L129
L118:
	MOV	EAX,DWORD [24+ESI+ECX*4]
	MOV	DWORD [20+ESI+ECX*4],EAX
	MOV	DWORD [24+EAX],ECX
	INC	ECX
	CMP	ECX,EBX
	JL	L118
L129:
	MOV	DWORD [20+ESI+EBX*4],EDI
L119:
	PUSH	EBX
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshmap
	PUSH	EBX
	JMP	L133
L113:
	MOV	ECX,DWORD [16+ESI]
	CMP	ECX,EBX
	JL	L131
L124:
	MOV	EDX,DWORD [20+ESI+ECX*4]
	LEA	EAX,DWORD [1+ECX]
	MOV	DWORD [24+ESI+ECX*4],EDX
	DEC	ECX
	MOV	DWORD [24+EDX],EAX
	CMP	ECX,EBX
	JGE	L124
L131:
	MOV	DWORD [20+ESI+EBX*4],EDI
	INC	DWORD [16+ESI]
	JMP	L119
	ALIGN	2
	GLOBAL	_sheet_refresh
_sheet_refresh:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	MOV	EAX,DWORD [24+EBX]
	TEST	EAX,EAX
	JS	L134
	PUSH	EAX
	PUSH	EAX
	MOV	ECX,DWORD [16+EBX]
	MOV	EAX,ECX
	ADD	ECX,DWORD [16+EBP]
	ADD	EAX,DWORD [24+EBP]
	PUSH	EAX
	MOV	EDX,DWORD [12+EBX]
	MOV	EAX,EDX
	ADD	EDX,DWORD [12+EBP]
	ADD	EAX,DWORD [20+EBP]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	DWORD [32+EBX]
	CALL	_sheet_refreshsub
	ADD	ESP,28
L134:
	MOV	EBX,DWORD [-4+EBP]
	LEAVE
	RET
	ALIGN	2
	GLOBAL	_sheet_slide
_sheet_slide:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	MOV	EAX,DWORD [32+EBX]
	MOV	EDI,DWORD [12+EBX]
	MOV	DWORD [-16+EBP],EAX
	MOV	ESI,DWORD [16+EBX]
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [12+EBX],EAX
	MOV	EAX,DWORD [16+EBP]
	MOV	DWORD [16+EBX],EAX
	CMP	DWORD [24+EBX],0
	JS	L136
	PUSH	0
	MOV	EAX,ESI
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,EDI
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	ESI
	PUSH	EDI
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshmap
	MOV	EAX,DWORD [16+EBP]
	PUSH	DWORD [24+EBX]
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,DWORD [12+EBP]
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	DWORD [16+EBP]
	PUSH	DWORD [12+EBP]
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshmap
	MOV	EAX,DWORD [24+EBX]
	ADD	ESP,48
	DEC	EAX
	PUSH	EAX
	MOV	EAX,ESI
	PUSH	0
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,EDI
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	ESI
	PUSH	EDI
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshsub
	MOV	EAX,DWORD [16+EBP]
	PUSH	DWORD [24+EBX]
	PUSH	DWORD [24+EBX]
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,DWORD [12+EBP]
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	DWORD [16+EBP]
	PUSH	DWORD [12+EBP]
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshsub
	ADD	ESP,56
L136:
	LEA	ESP,DWORD [-12+EBP]
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
	ALIGN	2
	GLOBAL	_sheet_free
_sheet_free:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	CMP	DWORD [24+EBX],0
	JS	L139
	PUSH	-1
	PUSH	EBX
	CALL	_sheet_updown
	POP	EAX
	POP	EDX
L139:
	MOV	DWORD [28+EBX],0
	MOV	EBX,DWORD [-4+EBP]
	LEAVE
	RET
